//package approval.dao;
//
//import java.io.BufferedReader;
//import java.io.FileInputStream;
//import java.io.IOException;
//import java.io.InputStreamReader;
//import java.sql.Connection;
//import java.sql.ResultSet;
//import java.sql.SQLException;
//import java.sql.Statement;
//import javax.faces.context.FacesContext;
//import javax.faces.event.ActionEvent;
//import javax.servlet.http.HttpSession;
//import model.util.ConnectionPool;
//import org.apache.commons.codec.DecoderException;
//
//import resource.pojo.Typedoc;
//
//public class EditorBean {
//
//	private String viewMode = "visual";
//	private String value;
//	private boolean liveUpdatesEnabled = false;
//	private static ConnectionPool connectionPool = null;
//
//	static {
//		try {
//			connectionPool = ConnectionPool.getConnectionPool();
//		} catch (Exception e) {
//			System.out.println("Error01:static block error!!");
//		}
//	}
//	
//	public ResultSet ExecuteQuery(String sql) {
//		Connection conn = null;
//		ResultSet rs = null;
//
//		try {
//			conn = connectionPool.getConnection();
//			Statement stmt = conn.createStatement();
//			rs = stmt.executeQuery(sql);
//		} catch (Exception e) {
//			e.printStackTrace();
//		} finally {
//			connectionPool.releaseConnection(conn);
//		}
//		return rs;
//	}
//
//	public void ExecuteUpdate(String sql) {
//		Connection conn = null;
//		try {
//			conn = connectionPool.getConnection();
//			Statement stmt = conn.createStatement();
//			stmt.executeUpdate(sql);
//
//			stmt.close();
//		} catch (Exception e) {
//			e.printStackTrace();
//		} finally {
//			connectionPool.releaseConnection(conn);
//		}
//	}
//
//	public EditorBean() {
//		value="ssssssssssssssssssssss";
//	}
//
//	public String getPathDoc() {
//		FacesContext f = FacesContext.getCurrentInstance();
//		String path = "";
//		HttpSession s = (HttpSession) f.getExternalContext().getSession(true);
//		Typedoc typeDoc = (Typedoc) s.getAttribute("TypeDoc");
//		Integer ID = typeDoc.getiDContentDoc();
//		String sql = "select Path from contentdoc where IDContentDoc="
//				+ ID.intValue();
//		ResultSet rs = this.ExecuteQuery(sql);
//		try {
//			while (rs.next()) {
//				path = rs.getString(1);
//			}
//		} catch (SQLException e) {
//			e.printStackTrace();
//		}
//		return path;
//	}
//
//	public void resetValue() {
//		value = "";
//	}
//
//	public String getValue() throws IOException, DecoderException {
//
////		FacesContext f = FacesContext.getCurrentInstance();
////		HttpServletRequest req = (HttpServletRequest) f.getExternalContext()
////				.getRequest();
////		String s = req.getParameter("fileInfo");
////		if (s != null) {
////			Base64 b = new Base64();
////			byte[] temp = (byte[]) b.decode(s);
////			value = new String(temp);
////		} else {
////			HttpSession ss = (HttpSession) f.getExternalContext().getSession(
////					true);
////			if (ss.getAttribute("new") != null) {
////				Boolean isNew = (Boolean) ss.getAttribute("new");
////				if (isNew) {
////					ServletContext sev = (ServletContext) f
////							.getExternalContext().getContext();
////					String a = f.getExternalContext().getRequestServletPath();
////					String urlTemp = sev.getRealPath(a);
////					System.out.println("RealPath :"+urlTemp);
////					String url = urlTemp.substring(0, urlTemp.lastIndexOf(File.separator))
////							+ File.separator
////							+ "TemplateDoc"+File.separator+getPathDoc();
////					System.out.println(url);
////					value = getHtml(url);
////				}
////				ss.setAttribute("new", new Boolean(false));
////			}
////
////		}
//
//		return value;
//	}
//
//	public void setValue(String value) {
//		this.value = value;
//	}
//
//	public boolean isLiveUpdatesEnabled() {
//		return liveUpdatesEnabled;
//	}
//
//	public void setLiveUpdatesEnabled(boolean liveUpdatesEnabled) {
//		this.liveUpdatesEnabled = liveUpdatesEnabled;
//	}
//
//	public String getViewMode() {
//		return viewMode;
//	}
//
//	public void setViewMode(String viewMode) {
//		this.viewMode = viewMode;
//	}
//
//	public void getSrcHtml(ActionEvent event) {
////
////		FacesContext f = FacesContext.getCurrentInstance();
////		HtmlEditor editor = (HtmlEditor) f.getViewRoot().findComponent(
////				"formmain:editor");
////		String strValue = editor.getValue().toString();
////		String sql = "update approvedoc set Content='" + strValue
////				+ "' where IDApproveDoc=1";
////		this.ExecuteUpdate(sql);
////		return;
//	}
//
//	public String getHtml(String htmlfile) {
//		String temp = "";
//		try {
//			BufferedReader b = new BufferedReader(new InputStreamReader(
//					new FileInputStream(htmlfile),"utf8"));
//			String line = "";
//			while ((line = b.readLine()) != null) {
//				temp = temp + line;
//			}
//			b.close();
//		} catch (IOException e) {
//			e.printStackTrace();
//		}
//		return temp;
//	}
//}